package com.easylinkin.linkappapi.deviceattribute.controller;

import com.easylinkin.linkappapi.annotation.CommonOperateLogAnnotate;
import com.easylinkin.linkappapi.deviceattribute.entity.DeviceAttributeTenantConfig;
import com.easylinkin.linkappapi.deviceattribute.service.DeviceAttributeTenantConfigService;
import com.easylinkin.linkappapi.operatelog.constant.LogConstant.LogModule;
import java.util.List;
import javax.annotation.Resource;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * <p>
 * 设备属性租户个性化配置 前端控制器
 * </p>
 *
 * @author TongJie
 * @since 2020-10-28
 */
@RestController
@Api(value="设备属性租户个性化配置",tags={"设备属性租户个性化配置"})
@RequestMapping("/deviceattribute/deviceAttributeTenantConfig")
public class DeviceAttributeTenantConfigController {

    @Resource
    private DeviceAttributeTenantConfigService service;

    @ApiOperation("批量新增设备属性租户个性化配置")
    @PostMapping("batchSaveDeviceAttributeTenantConfigs")
    @CommonOperateLogAnnotate(module = LogModule.DEVICE_ATTRIBUTE_TENANT_CONFIG, desc = "批量新增设备属性租户个性化配置")
    public RestMessage batchSaveDeviceAttributeTenantConfigs(@RequestBody List<DeviceAttributeTenantConfig> deviceAttributeTenantConfigList) {
        service.batchSaveDeviceAttributeTenantConfigs(deviceAttributeTenantConfigList);
        return RestBuilders.successBuilder().build();
    }

    @ApiOperation("根据条件查询设备属性租户个性化配置")
    @PostMapping("getDeviceAttributeTenantConfigs")
    public RestMessage getDeviceAttributeTenantConfigs(@RequestBody DeviceAttributeTenantConfig deviceAttributeTenantConfig) {
        List<DeviceAttributeTenantConfig> deviceAttributeTenantConfigs = service.getDeviceAttributeTenantConfigs(deviceAttributeTenantConfig);
        return RestBuilders.successBuilder().data(deviceAttributeTenantConfigs).build();
    }

}
